<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="day10.Emp"%>
<%@page import="entity.User"%>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><!--导入需要的标签所在的包-->
<html>
	<head>
	<title>Insert title here</title>
	<style type="text/css">
	.row1{
		background-color:red;
	}
	.row0{
		background-color:green;
	}
	
	</style>
	</head>
	<body>
		<% /*这些代码应该写到servlet,由servlet转发,这里忽略掉*/
		List<Emp> emps = new ArrayList<Emp>();
		for(int i=0;i<6;i++){
			Emp emp = new Emp();
			emp.setEname("name"+i);
			emp.setSalary(1500+200*i);
			emp.setAge(18+i);
			emps.add(emp);
		}
		pageContext.setAttribute("emps", emps);
		%>
		
		<h1>基础常用标签</h1>
		<h2>if标签</h2>
		${emps[2].ename }年龄:
		<c:if test="${emps[2].age>20}" >
		大于20
		</c:if>
		<c:if test="${emps[2].age<=20}" >
		小于等于20
		</c:if>
		<h2>choose标签</h2>
		${emps[3].ename }工资:
		<c:choose>
			<c:when test="${emps[3].salary>2000}">
			>2000
			</c:when>
			<c:when test="${emps[3].salary>1800}">
			>1800并且<=2000
			</c:when>
			<c:otherwise>
			<=1800
			</c:otherwise>
		</c:choose>
		<h2>forEach标签</h2>
		<table border="1" cellpadding="0" cellspacing="0">
		<tr><td>序号</td><td>员工</td><td>年龄</td><td>薪水</td><td>下标</td></tr>
		<c:forEach items="${emps}" var="e" varStatus="s">
		<tr class="row${s.count%2}"><td>${s.count}</td><td>${e.ename}</td><td>${e.age}</td><td>${e.salary}</td><td>${s.index}</td></tr>
		</c:forEach>
		</table>	
	</body>
</html>